#ifndef TWCORE_MAILCREATORDIALOG_H
#define TWCORE_MAILCREATORDIALOG_H

#include <QPushButton>
#include <QTextEdit>
#include <QLineEdit>
#include <QLabel>
#include "twcore_global.h"
namespace TWCore
{
	class TWCORE_EXPORT MailCreatorDialog : public QFrame
	{
		Q_OBJECT
		public:
			MailCreatorDialog();
			~MailCreatorDialog();

			void setIcon(const QPixmap& icon) { iconLabel.setPixmap(icon); }
			void setRecipientInfo(const QString& info) { nameLabel.setText(info); }
			void setHint(const QString& hint) { hintLabel.setText(hint); }
			void setResult(bool success);

			void setAutoClose(bool a) { b_autoClose = a; }

			QString getTitle() { return titleText.text(); }
			QString getContent() { return outText.toPlainText(); }

			void show(QObject* caller,bool showTitle = true);
			bool eventFilter(QObject*, QEvent*);
		signals:
			void sendButtonPressed(const QString& contentText,const QString& titleText);
			void closed();
			void occupiedByAnother();

		protected:
			void closeEvent(QCloseEvent*);
		private:
			QLabel			iconLabel;
			QLabel			nameLabel;
			QLabel			hintLabel;
			QPushButton		sendBtn;
			QLineEdit		titleText;
			QTextEdit		outText;
			QObject*	m_caller;
			bool b_autoClose;
		private slots:
			void updateSendBtn();
			void onSendBtnClicked();
	};
}
#endif // MAILCREATOR_H
